package com.bbs.web.controller;

import com.bbs.entity.Result;
import com.bbs.service.UpvoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName UpvoteController
 * @Description TODO
 * @Author geci
 * @Date 2019/9/23 10:15
 * @Version 1.0
 */
@RestController
@RequestMapping("/web/upvote")
public class UpvoteController {

    @Autowired
    private UpvoteService upvoteService;

    /**
     * 用户点赞
     * @param isupvote
     * @return
     */
    @GetMapping("/isUpvote")
    public Result isUpvote(Integer articleid, Integer isupvote, HttpServletRequest request){
        //获取用户名
        String username = (String)request.getSession().getAttribute("username");
        username = "admin";

        if (StringUtils.isEmpty(username)){
            return new Result(403,"请先登录！");
        }

        upvoteService.isUpvote(articleid,isupvote,username);
        return new Result();




    }


}
